window.addEventListener('load',function(){
  
    var oAdd = document.getElementById('add');
    var oName = document.getElementById('name');
    var oPass = document.getElementById('pass');
    var repass = document.getElementById('repass')
    oName.innerHTML = localStorage.userName;
    oPass.innerHTML = localStorage.passWord;
    
    oAdd.onclick = function () {
        var userName = oName.value;
        var passWord = oPass.value;
        var arr = [];
    
        function findArr() {
            for (var userName in localStorage) {
                arr.push(localStorage[userName]);
            }
            return arr;
        }
        var d = findArr();
        if (userName == d[1]) {
            alert('账户已注册');
            return false;
        } else if (passWord !== repass.value) {
            alert("两次密码输入不一致")
        } else if (oName.value == "" || oPass.value == '') {
            alert('不能为空');
        } else {
            localStorage.userName = userName;
            localStorage.passWord = passWord;
            alert('注册成功');
          location.href="../login.html"
        };
    
    }
  
       
})